package ooad.nextgen.domain;
import ooad.nextgen.gof.adapter.ITaxCalculatorAdapter;
import ooad.nextgen.gof.factory.TaxServiceFactory;

public class Register {
	private ProductCatalog catalog;
	private Sale currentSale;
	private ITaxCalculatorAdapter adapter;
	
	public ProductCatalog getCatalog() {
		return catalog;
	}
	public Sale getCurrentSale() {
		return currentSale;
	}
	public Register(ProductCatalog catalog) {
		this.catalog = catalog;
		this.adapter = TaxServiceFactory.getInstance().getTaxCalculatorAdapter();	
	}
	public void makeNewSale(){
		currentSale = new Sale();
	}
        public void enterItem(ItemId id, int quantity){
		ProductDescription desc = catalog.getProductDescription(id);
		currentSale.makeLineItem(desc, quantity);
	}
	public void endSale(){
		currentSale.becomeComplete();
		currentSale.getTotal();
	}
	public void makePayment(Money cashTendered){
		currentSale.makePayment(cashTendered);
		adapter.getTaxes(currentSale);	
	}
}
